package com.libreaccess.reporting.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.libredigital.reporting.schema.OutputFormat;
import com.libredigital.reporting.schema.ReportView;

public final class SimpleUtils {
	
	public static String formatCurrentDate() {
		SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
		return format.format(new Date());
	}
	
	public static final String formatCurrentDateAndTime() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
		return format.format(new Date()); 
	}

	public static boolean isViewinCollection(List<ReportView> rviews, ReportView view) {
		boolean result = false;
		if (rviews != null && view != null) {
			for (ReportView rv : rviews) {
				if (rv.getId() == view.getId())
					result = true;
			}
		}
		return result;
	}
	
	public static boolean isFormatinCollection(List<OutputFormat> frms, String f)
	{
		boolean result = false;
		if (frms != null && f != null) {
			for (OutputFormat of : frms) {
				if (of.getName().equalsIgnoreCase(f))
					result = true;
			}
		}
		return result;
	}

	public static boolean isStringEmpty(String s) {
		return (s == null || "".equals(s));
	}
}
